﻿/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: BasicModuleConfig.cpp
* Summary: 基础模块配置。
*
* Author: XuXiang
* Date: 2024-05-11 22:35
*******************************************************/

#include "BasicModuleConfig.h"
#include "../Util/StringUtil.h"
#include <iostream>
#include <algorithm>
using namespace std;

namespace Competition
{
	BasicModuleConfig::BasicModuleConfig()
	{
	}

	BasicModuleConfig::~BasicModuleConfig()
	{
		OnRelease();
	}

	void BasicModuleConfig::OnInit()
	{
		//常量
		ModuleConfig::LoadConfig<ConstConfig>(m_Consts, "Const");
		for (ConstConfigMap::iterator itr = m_Consts.begin(); itr != m_Consts.end(); ++itr)
		{
			m_NameToConst.insert(make_pair(itr->second->name, itr->second));
		}

		//角色
		ModuleConfig::LoadConfig<RoleConfig>(m_Roles, "Role");
	}

	void BasicModuleConfig::OnRelease()
	{
		m_NameToConst.clear();
		SAFE_DELETE_MAP(m_Consts);
		SAFE_DELETE_MAP(m_Roles);
	}
}